<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>门牌管理</title>
    <script th:src="@{/adminLTE/js/jquery-3.4.1.min.js}"></script>
    <script th:src="@{/layer/layer.js}"></script>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" th:href="@{/adminLTE/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/adminLTE/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/adminLTE/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- DataTables -->
    <link rel="stylesheet" th:href="@{/adminLTE/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/adminLTE/dist/css/adminlte.min.css}">
    <!-- adminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" th:href="@{/adminLTE/dist/css/skins/_all-skins.min.css}">


</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">

    <div th:replace="/common/header :: header"></div>

    <!-- Left side column. contains the logo and sidebar -->
    <div th:replace="/common/menu :: menu"></div>
        <!-- sidebar: style can be found in sidebar.less -->

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                门牌管理
                <a href="/doors/add">
                    <button id="createBtn" type="submit" class="btn btn-info" style="margin-left: 30px">添加</button>
                </a>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>门牌管理</a></li>
                <li class="active">门牌管理</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-12">
                    <table class="table table-hover" id="mytable1" th:object="${doors}">
                        <thead>
                        <th>door_Id</th>
                        <th>门牌（号）</th>
                        <th>街道编号</th>
                        <th>行政区编号</th>
                        <th>经度</th>
                        <th>纬度</th>
                        <th>类型</th>
                        <th>操作</th>

                        </thead>
                        <tbody>
                        <tr th:each="door:${doors}">

                            <td th:text="${door.doorId}"></td>
                            <td th:text="${door.doorName}"></td>
                            <td th:text="${door.streetId}"></td>
                            <td th:text="${door.districtId}"></td>
                            <td th:text="${door.lng}"></td>
                            <td th:text="${door.lat}"></td>
                            <td th:text="${door.type}"></td>
                            <td><a th:href="'/doors/edit?id=' + ${door.doorId}">修改</a>
                            <button type="submit" th:attr="onclick=|deleteDoor(this, '${door.doorId}')|">删除</button></td>

                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <div th:replace="/common/footer :: footer"></div>


</div>
<!-- ./wrapper -->

<!-- jQuery 3 -->
<script th:src="@{/adminLTE/bower_components/jquery/dist/jquery.min.js}"></script>
<!-- Bootstrap 3.3.7 -->
<script th:src="@{/adminLTE/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
<!-- DataTables -->
<script th:src="@{/adminLTE/bower_components/datatables.net/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/adminLTE/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js}"></script>
<!-- SlimScroll -->
<script th:src="@{/adminLTE/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
<!-- FastClick -->
<script th:src="@{/adminLTE/bower_components/fastclick/lib/fastclick.js}"></script>
<!-- adminLTE App -->
<script th:src="@{/adminLTE/dist/js/adminlte.min.js}"></script>
<!-- adminLTE for demo purposes -->
<script th:src="@{/adminLTE/js/demo.js}"></script>

<script>
    function deleteDoor(elem,id) {

        layer.confirm('确定要删除这条数据吗？',{icon:3,title:'提示'},function (index) {
            $.ajax(
                {
                    url: "/doors/delete?id=" + id,
                    type: "delete",
                    success:function (data) {
                        if (data == true) {
                            $(elem).parent().parent().remove();
                        }else {
                            console.log("删除失败");
                        }
                    },
                    fail: function (data) {
                        console.log(data);
                    }
                }
            )
            layer.close(index);
        });

    }
</script>
<!--page script-->
<script>
    $(function () {
        $('#mytable1').DataTable({
            "language": {
                "lengthMenu": "每页 _MENU_ 条记录",
                "zeroRecords": "没有找到记录",
                "info": "第 _PAGE_ 页 ( 总共 _PAGES_ 页 )",
                "infoEmpty": "无记录",
                "infoFiltered": "(从 _MAX_ 条记录过滤)",
                "search":"快速检索: ",
                "oPaginate": {
                    "sPrevious": "上页",
                    "sNext": "下页"
                }
            }

        })

    })
</script>
</body>
</html>
